package cn.com.nes.site.entity.em;

import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;

import java.util.Arrays;
import java.util.Map;
import java.util.stream.Collectors;

public enum FaultTypeEnum {
    _0("0","压缩机"),
    _1("1", "换热器"),
    _2("2", "循环水路"),
    _3("3", "冷媒循环"),
    _4("4", "其他"),
    ;

    private String key;

    private String value;

    FaultTypeEnum(String key, String value) {
        this.key = key;
        this.value = value;
    }

    public String getKey() {
        return key;
    }

    public String getValue() {
        return value;
    }

    public static String getVal(int key) {
        if (ObjectUtil.isNull(key)) return StrUtil.EMPTY;
        Map<String, String> map = Arrays.stream(values())
                .collect(Collectors.toMap(FaultTypeEnum::getKey, FaultTypeEnum::getValue));
        return map.get(String.valueOf(key));
    }
}
